package D01_03;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class Demo3 {
    public static void main(String[] args) throws IOException {
        for (Map.Entry<String, String> e : jiexi("src/Y2020/D01_03/1.txt").entrySet()) {
            System.out.print(e.getValue()+" ");
        }
    }
    public static Map<String,String> jiexi(String s) throws IOException {
        Map<String,String> map = new LinkedHashMap<>();
        File file = new File(s);
        List<String> strings = FileUtils.readLines(file);
        for (String str : strings) {
            str = str.replace("{", "");
            str = str.replace("}", "");
            str = str.replace("'", "");
            String[] split = str.split(",");
            for (String s1 : split) {
                map.put(s1.split(":")[0],s1.split(":")[1]);
            }
        }
        return map;
    }
}
